#include <bits/stdc++.h>
using namespace std;

int n,m,k;
int arr[205][205];
void func() {
    int tmp[205][205];
	if (n==m){
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j)
				tmp[i][j] = arr[n+1-j][i];
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j)
				arr[i][j] = tmp[i][j];
	} else {
		for(int i=1;i<=n;++i)
			for(int j=1;j<=m;++j)
				tmp[j][i]=arr[n+1-i][j];
		for(int i=1;i<=n;++i)
			for(int j=1;j<=m;++j)
				arr[j][i]=tmp[j][i];
    	swap(n,m);
	}
}
//1 2 3    4 1
//4 5 6 -> 5 2
//         6 3

int main() {
    cin >> n >> m >> k;
    k %= 4;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> arr[i][j];
    for (int i = 0; i < k; ++i)
        func();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j)
            cout << arr[i][j] << ' ';
        cout << endl;
    }
    return 0;
}